/**
 * @Author bian
 * @CreateDate 2017.3.2
 */
import { connect } from 'react-redux'
import UserCourseList from "../../components/user/UserCourseList/UserCourseList.jsx"

import {getCourses, filterCourse, sortCourse, changePage} from "../../actions/user/course_list_actions"

const mapDispatchToProps = (dispatch) => {
    return {
        init : () => {
            dispatch(getCourses())
        },
        filter : (major) => {
            dispatch(filterCourse(major))
        },
        sort : (gist) => {
            dispatch(sortCourse(gist))
        },
        changePage : (page) => {
            dispatch(changePage(page))
        }
    }
}

const mapStateToProps = (state,ownProps) => {
    const {userCourseList} = state
    return userCourseList
    // {
    //     courses : userCourseList.courses,
    //         page : userCourseList.page,
    //     limit : userCourseList.limit,
    //     totalPage : userCourseList.totalPage
    // }
}

const UserCourseListContainer = connect(
    mapStateToProps,
    mapDispatchToProps
)(UserCourseList)

exports.UserCourseListContainer = UserCourseListContainer